<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="chtml" uri="http://www.szhelper.com/jsp/html"%>
<%@page import="com.hengpeng.itfinoss.controller.util.PageHandlerUtil"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="com.hengpeng.itfinbase.persist.ShortcutMenu"%>
<%@page import="com.hengpeng.itfinbase.persist.ShortcutMenuNode"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>更新快捷菜单</title>
<script type="text/javascript">
function insertRow()
{
	var tab = document.getElementById("fatorage_table");
	var newTr = tab.insertRow(tab.rows.length);
	var newTd = newTr.insertCell(0);
	newTd.innerHTML = '链接名称&nbsp;<input type="text" name="linsName"style="width: 100px;" />&nbsp;排序&nbsp;<input type="text" style="width: 40px;" value="10" name="sorts" />&nbsp;链接地址&nbsp;<input type="text" style="width: 500px;" name="urls" /><span style="color:red;">*</span>&nbsp;&nbsp;<a href="#" onclick="del(this);">删除</a>';
}
function del(a) {
	var tab = document.getElementById("fatorage_table");
	var tr = a.parentNode.parentNode;
	tab.deleteRow(tr.rowIndex);
}

function onsubmits(){
	var names = document.getElementsByName("linsName");
	var sorts = document.getElementsByName("sorts");
	var urls = document.getElementsByName("urls");
	for(var i=0;i<names.length;i++) {
		var text = names[i].value;
		if(helper.fun.validateEmpty(text)) {
			alert('链接名称不能为空!');
			return false;
		}
	}
	for(var i=0;i<sorts.length;i++) {
		var text = sorts[i].value;
		if(!helper.fun.validateInt(text)){
			alert('排序字段只能输入正整数！');
			return false;
		}
	}
	for(var i=0;i<urls.length;i++) {
		var text = urls[i].value;
		if(helper.fun.validateEmpty(text)){
			alert('url地址不能为空！');
			return false;
		}
	}
	return true;
}
</script>
</head>
<body>
<div class="youarehere">权限管理 &gt; <span>更新快捷菜单</span></div>
<%
ShortcutMenu m = (ShortcutMenu)request.getAttribute("sharemenu");
%>
<chtml:command command="sharemenu" title="创建快捷菜单" exclude="isShare,userId"
	onSubmit="onsubmits()" action="/acm/menu/modify" column="1">

	<%
	if(PageHandlerUtil.getUserNo(session).equals("admin")) {	
		if(m.getIsShare()!=null && m.getIsShare() == com.hengpeng.common.persist.entity.AbstractEntity.BoolValue.YES)
		{
			%>
			<chtml:property index="-1" label="是否共享">
		<input type="radio" value="NO" name="isShare">否
		<input type="radio" value="YES" name="isShare" checked="checked">是 
		</chtml:property>
			<%
		}else{
			%>
			<chtml:property index="-1" label="是否共享">
		<input type="radio" value="NO" name="isShare" checked="checked">否
		<input type="radio" value="YES" name="isShare">是 
		</chtml:property>
			<%
		}
	}
	%>

	<chtml:property index="-1" label="子链接">
		<div id="havefatorage_div" style="display: block;">
		<table id="fatorage_table" class="data_table_main" border="0">
			<%
			if(m.getNodeSet()!=null && m.getNodeSet().size()>0) {
				for(ShortcutMenuNode node : m.getNodeSet()) {
					%>
					<tr><td>
					链接名称&nbsp;<input type="text" value="<%=node.getName() %>" name="linsName"style="width: 100px;" />&nbsp;排序&nbsp;<input type="text" style="width: 40px;" value="<%=node.getSortLevel() %>" name="sorts" />&nbsp;链接地址&nbsp;<input type="text" style="width: 500px;" value="<%=node.getUrl() %>" name="urls" /><span style="color:red;">*</span>&nbsp;&nbsp;<a href="#" onclick="del(this);">删除</a>
					</td></tr>
					<%
				}
			}
			%>
		</table>
		<input type="button" style="margin-top: 10px;" onclick="insertRow();"
			value="添加链接菜单"></input></div>
	</chtml:property>
	<chtml:button destination="/acm/menu/modify" showText="更新"></chtml:button>
</chtml:command>
</body>
</html>